﻿// API请求函数
const fetchData = async () => {
  loading.value = true
  try {
    const params = new URLSearchParams({
      PageIndex: pagination.currentPage.toString(),
      PageSize: pagination.pageSize.toString(),
      ...(searchForm.consignorUnit && { ConsignorUnit: searchForm.consignorUnit }),
      ...(searchForm.paymentMethod && { PaymentMethod: searchForm.paymentMethod }),
      ...(searchForm.approvalStatus && { ApprovalStatus: searchForm.approvalStatus }),
      ...(searchForm.handler && { Handler: searchForm.handler }),
      ...(searchForm.businessDate && { BusinessDate: searchForm.businessDate })
    })

    const response = await fetch(/api/ReceivableFee/GetPayableFees?, {
      method: 'GET',
      headers: {
        'accept': 'text/plain',
        'Content-Type': 'application/json'
      }
    })

    if (!response.ok) {
      throw new Error(HTTP error! status: )
    }

    const result: ApiResponse = await response.json()
    
    if (result.code === 200) {
      // 为每个数据项添加selected属性
      tableData.value = result.data.data.map(item => ({
        ...item,
        selected: false
      }))
      
      pagination.totalCount = result.data.totalCount
      pagination.totalPage = result.data.totalPage
    } else {
      console.error('API返回错误:', result.message)
      tableData.value = []
    }
  } catch (error) {
    console.error('请求失败:', error)
    tableData.value = []
  } finally {
    loading.value = false
  }
}
